package com.cqeec.ui;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class BookFindPanel extends JPanel {
	JCheckBox cbIsbn;
	JCheckBox cbName;
	JCheckBox cbPrice;
	JCheckBox cbPublishDate;
	JCheckBox cbAuthor;
	JCheckBox cbPublisher;
	JCheckBox cbType;
	JLabel lbIsbn;
	JTextField txtIsbn;
	JLabel lbName;
	JTextField txtName;
	JLabel lbPrice;
	JTextField txtMinPrice, txtMaxPrice;
	JLabel lbAuthor;
	JTextField txtAuthor;
	JComboBox Type;
	JLabel lbType;
	JLabel lbPublisher;
	JTextField txtPublisher;
	JLabel lbPublishDate;
	JTextField txtStartDate, txtEndDate;
	String flag = "";

	public BookFindPanel() {
		BookFrame.lbState.setText("状态：请输入查询条件");
		BookFrame.saveBtn.setEnabled(false);
		BookFrame.returnBtn.setEnabled(true);
		BookFrame.addBtn.setEnabled(false);
		BookFrame.modBtn.setEnabled(false);
		BookFrame.delBtn.setEnabled(false);
		BookFrame.findBtn.setEnabled(true);
		this.setLayout(null);
		initGUI();
	}

	// GUI界面设置
	private void initGUI() {
		try {
			this.setPreferredSize(new java.awt.Dimension(443, 234));

			cbIsbn = new JCheckBox();
			this.add(cbIsbn);
			cbIsbn.setBounds(27, 25, 23, 17);
			lbIsbn = new JLabel();
			this.add(lbIsbn);
			lbIsbn.setText("图书编号:");
			lbIsbn.setBounds(50, 26, 72, 15);
			txtIsbn = new JTextField();
			this.add(txtIsbn);
			txtIsbn.setBounds(122, 23, 187, 22);

			cbName = new JCheckBox();
			this.add(cbName);
			cbName.setBounds(27, 65, 23, 17);
			lbName = new JLabel();
			this.add(lbName);
			lbName.setText("图书名称:");
			lbName.setBounds(50, 66, 72, 15);
			txtName = new JTextField();
			this.add(txtName);
			txtName.setBounds(122, 63, 187, 22);

			cbType = new JCheckBox();
			this.add(cbType);
			cbType.setBounds(27, 105, 23, 17);
			lbType = new JLabel();
			this.add(lbType);
			lbType.setText("图书类别:");
			lbType.setBounds(50, 106, 72, 15);
			ComboBoxModel xbBoxModel = new DefaultComboBoxModel(new String[] {
					"经济管理", "计算机", "文学", "小说", "社会科学", "考试辅导" });
			Type = new JComboBox();
			this.add(Type);
			Type.setModel(xbBoxModel);
			Type.setBounds(122, 103, 187, 22);
			
			cbAuthor = new JCheckBox();
			this.add(cbAuthor);
			cbAuthor.setBounds(27, 145, 23, 17);
			lbAuthor = new JLabel();
			this.add(lbAuthor);
			lbAuthor.setText("图书作者:");
			lbAuthor.setBounds(50, 146, 72, 15);
			txtAuthor = new JTextField();
			this.add(txtAuthor);
			txtAuthor.setBounds(122, 143, 187, 22);
			
			cbPublisher = new JCheckBox();
			this.add(cbPublisher);
			cbPublisher.setBounds(27, 185, 23, 17);
			lbPublisher = new JLabel();
			this.add(lbPublisher);
			lbPublisher.setText("出版社:");
			lbPublisher.setBounds(50, 186, 72, 15);
			txtPublisher = new JTextField();
			this.add(txtPublisher);
			txtPublisher.setBounds(122, 183, 187, 22);
			
			cbPublishDate = new JCheckBox();
			this.add(cbPublishDate);
			cbPublishDate.setBounds(27, 225, 23, 17);
			lbPublishDate = new JLabel();
			this.add(lbPublishDate);
			lbPublishDate.setText("出版日期:");
			lbPublishDate.setBounds(50, 226, 72, 15);
			txtStartDate = new JTextField();
			txtStartDate.setToolTipText("输入格式：yyyy-MM-dd");
			this.add(txtStartDate);
			txtStartDate.setBounds(122, 223, 187, 22);
			JLabel label1 = new JLabel("至");
			this.add(label1);
			label1.setBounds(320, 226, 72, 15);
			txtEndDate = new JTextField();
			txtEndDate.setToolTipText("输入格式：yyyy-MM-dd");
			this.add(txtEndDate);
			txtEndDate.setBounds(345, 223, 187, 22);
			
			cbPrice = new JCheckBox();
			this.add(cbPrice);
			cbPrice.setBounds(27, 265, 23, 17);
			lbPrice = new JLabel();
			this.add(lbPrice);
			lbPrice.setText("图书价格:");
			lbPrice.setBounds(50, 266, 72, 15);
			txtMinPrice = new JTextField();
			txtMinPrice.setToolTipText("输入数字");
			this.add(txtMinPrice);
			txtMinPrice.setBounds(122, 263, 187, 22);
			JLabel label2 = new JLabel("至");
			this.add(label2);
			label2.setBounds(320, 266, 72, 15);
			txtMaxPrice = new JTextField();
			txtMaxPrice.setToolTipText("输入数字");
			this.add(txtMaxPrice);
			txtMaxPrice.setBounds(345, 263, 187, 22);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
